<?php

include_once 'mysqlpdo.php';
include_once 'ilogincomumdao.php';
class LoginComumDAOMySQL extends MySQLPDO implements ILoginComumDAO {        
    public function __construct($driver_options=array(PDO::ATTR_PERSISTENT => true)) {        
        parent::__construct($driver_options);        
    }
    
    public function add(LoginComum $l) {        
        $stmt = $this->prepare("INSERT INTO LOGIN (log_user, log_senha) VALUES (:user, :senha)");
        $stmt->bindParam(':user', $user);
        $stmt->bindParam(':senha', $senha);

        //ou $stmt = $this->prepare("INSERT INTO LOGIN (log_user, log_senha) VALUES (?, ?)");
        //$stmt->bindParam(1, $user);
        //$stmt->bindParam(2, $senha);        

        $user = $l->getUsuario();
        $senha= $l->getSenha();                
        //$user = 'x';
        //$senha = 'y';                
        $stmt->execute();
        return $stmt;        
    }

    public function atualiza(LoginComum $l) {
        return $this->query("UPDATE LOGIN SET log_senha = ? WHERE log_user = ?", $l->getSenha(), $l->getUsuario());
    }

    public function busca($usuario) {
        return $this->query("SELECT * FROM LOGIN where log_user = ?", $usuario);
    }

    public function remove($usuario) {
        return $this->query("DELETE FROM LOGIN where log_user = ?", $usuario);
    }
}
?>